#include "backdrop_part2d_fx.h"
#include "camera/abstract_camera.h"
#include "math/plane.h"
#include "part2d/part2d.h"
#include "num/rand.h"

#include "util/timer.h"				// log
#include "util/log.h"				// log
#include "util/common_macros.h"		// macros
#include "util/mmgr.h"		    

using namespace backdrop;

BackdropPart2DBackgdropSFXSet::BackdropPart2DBackgdropSFXSet(camera::AbstractCamera* pCam, BackdropSFX*	pParent) : 
	BackgdropSFXSet(pCam, pParent),
	m_pSys(NULL)
{


}

BackdropPart2DBackgdropSFXSet::~BackdropPart2DBackgdropSFXSet()
{
	UTIL_SAFE_DELETE(m_pSys);

}
void	BackdropPart2DBackgdropSFXSet::Render()
{
	if (m_pSys)
	{
		m_pSys->Render(m_pParent->GetOffset(), 1);
	}
}
void	BackdropPart2DBackgdropSFXSet::Tick(float dt)
{
	if (m_pSys)
	{
		m_pSys->Tick(dt);
	}
}
void	BackdropPart2DBackgdropSFXSet::Load(const std::string& File)
{
	UTIL_SAFE_DELETE(m_pSys);
	m_pSys = new part2d::Part2D();
	m_pSys->Load(File);
}
void	BackdropPart2DBackgdropSFXSet::TriggerParticles(float Count, const math::Vec2& Pos, const math::Vec2& Size)
{
	if (m_pSys)
	{
	   num::RAND32& Rnd = num::RAND32::Instance();
	   for (int i=0; i<Count; i++)
	   {
		   m_pSys->TriggerParticles(Pos + Rnd.RandVec2(math::Vec2(0,0), Size));
	   }
	}
}

void	BackdropPart2DBackgdropSFXSet::TriggerParticles(float Count, const math::Vec2& Pos)
{
	if (m_pSys)
	{
	   for (int i=0; i<Count; i++)
	   {
		   m_pSys->TriggerParticles(Pos);
	   }
	}
}

